package com.efun.center.datasource;

public enum DataSourceMap {

    manager, // 后台
    hk_tw, // 港台225
    hk_tw_core_slave,    // 港台227
    hk_tw_extend_master, // 港台从库231
    hk_tw_extend_slave, // 港台从库232
    taiwan,//台湾新平台（基础主库）
    taiwan_core_slave,//台湾新平台（基础从库）
    taiwan_extend_master, //台湾新平台（拓展主库）
    taiwan_extend_slave, //台湾新平台（拓展从库）
    korea, // 韩国（主）
    korea_vice, // 韩国（从）
    korea_kq, // 韩国Qfun（主）
    korea_kq_vice, // 韩国Qfun（从）
    kl, // 韩国联运（主）
    kl_vice,// 韩国联运（从）
    asia, // 亚欧基础主库
    asia_core_slave, // 亚欧基础从库
    asia_extend_master, // 亚欧拓展主库
    asia_extend_slave, // 亚欧拓展从库
    indonesia, // 印尼基础主库
    indonesia_core_slave, // 印尼基础从库
    indonesia_extend_master, // 印尼拓展主库
    indonesia_extend_slave, // 印尼拓展从库
    vietnam2,    // 越南2 指向亚欧基础主库
    vietnam2_core_slave,    // 越南2 指向亚欧基础从库
    vietnam2_extend_master,    // 越南2,指向亚欧拓展主库
    vietnam2_extend_slave,    // 越南2,指向亚欧拓展从库
    thailand, // 泰国
    middle_east, // 中东
    japan, // 日本
    america, // 亚欧全球
    global; // 全球中心

    public static DataSourceMap getDataSourceMap(String area) {
        for (DataSourceMap s : DataSourceMap.values()) {
            if (s.name().equals(area)) {
                return s;
            }
        }
        return null;
    }

    public static DataSourceMap getCoreDataSource(DataSourceMap currentDS, boolean needMaster) {
        switch (currentDS) {
            case hk_tw:
            case hk_tw_core_slave:
            case hk_tw_extend_master:
            case hk_tw_extend_slave:
                if (needMaster) {
                    return DataSourceMap.hk_tw;
                } else {
                    return DataSourceMap.hk_tw_core_slave;
                }
            case taiwan:
            case taiwan_core_slave:
            case taiwan_extend_master:
            case taiwan_extend_slave:
                if (needMaster) {
                    return DataSourceMap.taiwan;
                } else {
                    return DataSourceMap.taiwan_core_slave;
                }
            case asia:
            case asia_core_slave:
            case asia_extend_master:
            case asia_extend_slave:
                if (needMaster) {
                    return DataSourceMap.asia;
                } else {
                    return DataSourceMap.asia_core_slave;
                }
            case indonesia:
            case indonesia_core_slave:
            case indonesia_extend_master:
            case indonesia_extend_slave:
                if (needMaster) {
                    return DataSourceMap.indonesia;
                } else {
                    return DataSourceMap.indonesia_core_slave;
                }
            case vietnam2:
            case vietnam2_core_slave:
            case vietnam2_extend_master:
            case vietnam2_extend_slave:
                if (needMaster) {
                    return DataSourceMap.vietnam2;
                } else {
                    return DataSourceMap.vietnam2_core_slave;
                }
            case korea:
            case korea_vice:
                if (needMaster) {
                    return DataSourceMap.korea;
                } else {
                    return DataSourceMap.korea_vice;
                }
            case korea_kq:
            case korea_kq_vice:
                if (needMaster) {
                    return DataSourceMap.korea_kq;
                } else {
                    return DataSourceMap.korea_kq_vice;
                }
            case kl:
            case kl_vice:
                if (needMaster) {
                    return DataSourceMap.kl;
                } else {
                    return DataSourceMap.kl_vice;
                }
            default:
                return currentDS;
        }
    }

    public static DataSourceMap getExtendDataSource(DataSourceMap currentDS, boolean needMaster) {
        switch (currentDS) {
            case hk_tw:
            case hk_tw_core_slave:
            case hk_tw_extend_master:
            case hk_tw_extend_slave:
                if (needMaster) {
                    return DataSourceMap.hk_tw_extend_master;
                } else {
                    return DataSourceMap.hk_tw_extend_slave;
                }
            case taiwan:
            case taiwan_core_slave:
            case taiwan_extend_master:
            case taiwan_extend_slave:
                if (needMaster) {
                    return DataSourceMap.taiwan_extend_master;
                } else {
                    return DataSourceMap.taiwan_extend_slave;
                }
            case asia:
            case asia_core_slave:
            case asia_extend_master:
            case asia_extend_slave:
                if (needMaster) {
                    return DataSourceMap.asia_extend_master;
                } else {
                    return DataSourceMap.asia_extend_slave;
                }
            case indonesia:
            case indonesia_core_slave:
            case indonesia_extend_master:
            case indonesia_extend_slave:
                if (needMaster) {
                    return DataSourceMap.indonesia_extend_master;
                } else {
                    return DataSourceMap.indonesia_extend_slave;
                }
            case vietnam2:
            case vietnam2_core_slave:
            case vietnam2_extend_master:
            case vietnam2_extend_slave:
                if (needMaster) {
                    return DataSourceMap.vietnam2_extend_master;
                } else {
                    return DataSourceMap.vietnam2_extend_slave;
                }
            case korea:
            case korea_vice:
                if (needMaster) {
                    return DataSourceMap.korea;
                } else {
                    return DataSourceMap.korea_vice;
                }
            case korea_kq:
            case korea_kq_vice:
                if (needMaster) {
                    return DataSourceMap.korea_kq;
                } else {
                    return DataSourceMap.korea_kq_vice;
                }
            case kl:
            case kl_vice:
                if (needMaster) {
                    return DataSourceMap.kl;
                } else {
                    return DataSourceMap.kl_vice;
                }
            default:
                return currentDS;
        }
    }

}
